package leetcode;

public class l0350_383_赎金信 {

    public boolean canConstruct(String ransomNote, String magazine) {
        if (ransomNote == null || ransomNote.isEmpty() || magazine == null || magazine.isEmpty()) {
            return false;
        }
        char[] ransomNotes = ransomNote.toCharArray();
        char[] magazines = magazine.toCharArray();

        int[] chars = new int[26];
        for (char character : magazines) {
            chars[character - 'a']++;
        }
        for (char character : ransomNotes) {
            chars[character - 'a']--;
            if (chars[character - 'a'] < 0) {
                return false;
            }
        }
        return true;
    }
}

